package com.mall.common.dao;

import java.sql.DriverManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mall.untils.PropertiesUtil;
import com.mysql.jdbc.Connection;

public class PhpsqlDBManager {
	private static Logger logger = LoggerFactory.getLogger(PhpsqlDBManager.class);
	private static Connection conn = null;
	private static String url = PropertiesUtil.getJdbcProperties("jdbc.huiku.url");
	private static String userName = PropertiesUtil.getJdbcProperties("jdbc.huiku.username");
	private static String password = PropertiesUtil.getJdbcProperties("jdbc.huiku.password");
	static{
		try{
		  //注册驱动
		  DriverManager.registerDriver(new com.mysql.jdbc.Driver());
		  //建立连接
		  conn = (Connection) DriverManager.getConnection(url,  userName, password);
		  //不执行自动提交
		  conn.setAutoCommit(false);   
		}catch(Exception e){
			logger.info("jdbc链接异常："+e.getMessage());
		}
	}
	
	/**
	 * 获取PreparedStatement对象
	 * @return
	 */
	public static Connection getConnection(){
		return conn;
	}
}
